home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / dos / createdir.c < prev    next >
C/C++ Source or Header  |  1996-10-24  |  3KB  |  101 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: createdir.c,v 1.3 1996/10/24 15:50:25 aros Exp $
  4.     $Log: createdir.c,v $
  5.     Revision 1.3  1996/10/24 15:50:25  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.2  1996/09/21 14:14:22  digulla
  9.     Hand DOSBase to DoName()
  10.  
  11.     Revision 1.1  1996/09/11 12:54:45  digulla
  12.     A couple of new DOS functions from M. Fleischer
  13.  
  14.     Desc:
  15.     Lang: english
  16. */
  17. #include <exec/memory.h>
  18. #include <clib/exec_protos.h>
  19. #include <utility/tagitem.h>
  20. #include <dos/dos.h>
  21. #include <dos/filesystem.h>
  22. #include <clib/dos_protos.h>
  23. #include <clib/utility_protos.h>
  24. #include "dos_intern.h"
  25.  
  26. /*****************************************************************************
  27.  
  28.     NAME */
  29.     #include <clib/dos_protos.h>
  30.  
  31.     AROS_LH1(BPTR, CreateDir,
  32.  
  33. /*  SYNOPSIS */
  34.     AROS_LHA(STRPTR, name, D1),
  35.  
  36. /*  LOCATION */
  37.     struct DosLibrary *, DOSBase, 20, Dos)
  38.  
  39. /*  FUNCTION
  40.     Creates a new directory under the given name. If all went an
  41.     exclusive lock on the new diretory is returned.
  42.  
  43.     INPUTS
  44.     name       - NUL terminated name.
  45.  
  46.     RESULT
  47.     Exclusive lock to the new directory or 0 if couldn't be created.
  48.     IoErr() gives additional information in that case.
  49.  
  50.     NOTES
  51.  
  52.     EXAMPLE
  53.  
  54.     BUGS
  55.  
  56.     SEE ALSO
  57.  
  58.     INTERNALS
  59.  
  60.     HISTORY
  61.     29-10-95    digulla automatically created from
  62.                 dos_lib.fd and clib/dos_protos.h
  63.  
  64. *****************************************************************************/
  65. {
  66.     AROS_LIBFUNC_INIT
  67.     AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
  68.  
  69.     struct FileHandle *ret;
  70.  
  71.     /* Get pointer to process structure */
  72.     struct Process *me=(struct Process *)FindTask(NULL);
  73.  
  74.     /* Get pointer to I/O request. Use stackspace for now. */
  75.     struct IOFileSys io,*iofs=&io;
  76.  
  77.     /* Allocate memory for lock */
  78.     ret=(struct FileHandle *)AllocDosObject(DOS_FILEHANDLE,NULL);
  79.     if(ret!=NULL)
  80.     {
  81.     /* Prepare I/O request. */
  82.     iofs->IOFS.io_Message.mn_Node.ln_Type=NT_REPLYMSG;
  83.     iofs->IOFS.io_Message.mn_ReplyPort   =&me->pr_MsgPort;
  84.     iofs->IOFS.io_Message.mn_Length      =sizeof(struct IOFileSys);
  85.     iofs->IOFS.io_Flags=0;
  86.     iofs->IOFS.io_Command=FSA_CREATE_DIR;
  87.     /* io_Args[0] is the name which is set by DoName(). */
  88.     iofs->io_Args[1]=FIBF_READ|FIBF_WRITE|FIBF_EXECUTE|FIBF_DELETE;
  89.     if(!DoName(iofs,name,DOSBase))
  90.     {
  91.         ret->fh_Unit  =iofs->IOFS.io_Unit;
  92.         ret->fh_Device=iofs->IOFS.io_Device;
  93.         return MKBADDR(ret);
  94.     }
  95.     FreeDosObject(DOS_FILEHANDLE,ret);
  96.     }else
  97.     me->pr_Result2=ERROR_NO_FREE_STORE;
  98.     return 0;
  99.     AROS_LIBFUNC_EXIT
  100. } /* CreateDir */
  101.